package com.cwt_taxi_xa;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MessageFunctionActivity extends CWTBaseActivity implements OnClickListener{

	private GridView gridview;
	private List<Map<String, Object>> dataList;
	private SimpleAdapter adapter;
	private TextView showtime;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_function);

		setupViews();
		addListener();
		initData();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	private void setupViews() {
		// TODO Auto-generated method stub
		showtime = (TextView)findViewById(R.id.showtime);
		showtime.setVisibility(View.VISIBLE);
		showtime.setText("调度信息");

		gridview = (GridView) findViewById(R.id.gridview);
		gridview.setSelector(new ColorDrawable(Color.TRANSPARENT));
	}

	private void addListener() {
		// TODO Auto-generated method stub
		gridview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int position,
									long arg3) {
				// TODO Auto-generated method stub
				doNext(position);
			}
		});
	}

	protected void doNext(int position) {
		// TODO Auto-generated method stub
		switch (position) {
			case 0:
				startActivity(new Intent(this, MessageList.class));
				break;
			case 1:
				startActivity(new Intent(this, EventList.class));
				break;
			case 2:
				startActivity(new Intent(this, QuestionList.class));
				break;
			case 3:
				startActivity(new Intent(this, ContactActivity.class));
				break;
			case 4:
				startActivity(new Intent(this, BusinessCount.class));
				break;
			case 5:
				startActivity(new Intent(this, CheckinDataList.class));
				break;
			case 6:
				startActivity(new Intent(this, CheckoutDataList.class));
				break;

			default:
				break;
		}
	}

	private void initData() {
		// TODO Auto-generated method stub
		//图标
		int icno[] = { R.drawable.ic_star, R.drawable.ic_star, R.drawable.ic_star,
				R.drawable.ic_star, R.drawable.ic_star, R.drawable.ic_star,
				R.drawable.ic_star};
		//图标下的文字
		String name[]={"文本信息","事件信息","提问信息","电话本","营运数据","签到数据","签退数据"};
		dataList = new ArrayList<Map<String, Object>>();
		for (int i = 0; i <icno.length; i++) {
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("img", icno[i]);
			map.put("text",name[i]);
			dataList.add(map);
		}

		String[] from={"img","text"};
		int[] to={R.id.img,R.id.text};
		adapter=new SimpleAdapter(this, dataList, R.layout.gridview_item, from, to);
		gridview.setAdapter(adapter);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		/*switch (v.getId()) {
		case R.id.zhongbiaoLin:
			break;
		}*/
	}

	@Override
	public void setStatus(int index, boolean status) {
		// TODO Auto-generated method stub

	}

	@Override
	public void sendMsg(int type, Object obj) {
		// TODO Auto-generated method stub

	}

	/*public class FunctionInfo{

		private String name;
		private int id;
		private int iconId;

		public FunctionInfo() {
			super();
		}

		public FunctionInfo(String name, int id, int iconId) {
			super();
			this.name = name;
			this.id = id;
			this.iconId = iconId;
		}

		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public int getId() {
			return id;
		}
		public void setId(int id) {
			this.id = id;
		}
		public int getIconId() {
			return iconId;
		}
		public void setIconId(int iconId) {
			this.iconId = iconId;
		}
	}*/
}
